<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>网络跟踪学生添加页面</title>
<link rel="stylesheet" href="layui/css/layui.css" media="all">
<style>
.layui-btn:not(.layui-btn-lg ):not(.layui-btn-sm):not(.layui-btn-xs) {
	height: 34px;
	line-height: 34px;
	padding: 0 8px;
}
</style>
</head>
<body>
	<form class="layui-form" action="">
	<div class="layui-form-item" style="margin-top: 20px;" onsubmit="false">
		<div class="layui-form-item" hidden="hidden">
				<label class="layui-form-label required">跟踪者:</label>
				<div class="layui-input-inline" style="width: 350px;">
					<input type="text" name="userid"  id="userid" lay-verify="required" lay-reqtext="跟踪者id获取失败" placeholder="请输入跟踪者id" value="" class="layui-input">
				</div>
			</div>
		<div class="layui-form-item" hidden="hidden">
				<label class="layui-form-label required">跟踪学生姓名:</label>
				<div class="layui-input-inline" style="width: 350px;">
					<input type="text" name="stuid" id="stuid"  lay-verify="required" lay-reqtext="跟踪学生姓名不能为空" placeholder="请输入跟踪学生姓名" value="" class="layui-input">
				</div>
		</div>
			<div class="layui-form-item">
				<label class="layui-form-label" style="width: 120px;">跟踪类型:</label>
				<div class="layui-input-inline" style="width: 350px;">
				<select name="tracktype" id="tracktype"  lay-search>
									<option value=""></option>
									<option value="电话">电话</option>
								    <option value="EMAIL">EMAIL</option>
								    <option value="短信">短信</option>
								    <option value="当面">当面</option>
								</select>
				</div>
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label" style="width: 120px;">跟踪状态:</label>
				<div class="layui-input-inline" style="width: 120;">
							<select name="trackstate" id="trackstate" class="layui-input">
								<option value="">请选择状态</option>
								<option value="1">已完成</option>
								<option value="2">跟进中</option>
								<option value="3">未完成</option>
							</select>
						</div>
			</div>
			<div class="layui-form-item layui-form-text">
				<label class="layui-form-label" style="width: 120px;">跟踪内容:</label>
				<div class="layui-input-inline" style="width: 350px;">
					<textarea name="trackcontent" placeholder="请输入跟踪内容" class="layui-textarea"></textarea>
				</div>
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label" style="width: 120px;">跟踪时间:</label>
				<div class="layui-input-inline" style="width: 350px;">
					<input type="text" name="trackdatebegin" id="trackdatebegin" placeholder="请输入开始跟踪时间" lay-verify="required" class="layui-input">
				</div>
			</div>	
			<div class="layui-form-item">
				<label class="layui-form-label" style="width: 120px;">创建跟踪的时间:</label>
				<div class="layui-input-inline" style="width: 350px;">
					<input type="text" name="trackcreatetime" id="trackcreatetime" placeholder="请输入开始跟踪时间" lay-verify="required" class="layui-input">
				</div>
			</div>	
		
		<div class="layui-btn-container" style="text-align: center;">
			<button class="layui-btn" lay-filter="trackstudentsBtu" lay-submit="">
				添加</button>
		</div>
	</div>
	</form>
	<script type="text/javascript" src="layui/layui.js"></script>
	<script src="js/Global.js" type="text/javascript" charset="utf-8"></script>
		<script>
			layui.use(['form','laydate'], function() {
				var form = layui.form,
					layer = layui.layer,
					$ = layui.$;
				var laydate = layui.laydate;
		
				//执行一个laydate实例
				laydate.render({
				  elem: '#trackdatebegin' //指定元素
				  ,type: 'datetime'
				  ,trigger: 'click' //采用click弹出
				  ,calendar: true //允许显示公历节日
				});
				
				laydate.render({
					  elem: '#trackcreatetime' //指定元素
					  ,type: 'datetime'
					  ,trigger: 'click' //采用click弹出
					  ,calendar: true //允许显示公历节日
					});
				form.verify({
					username: function(value, item) { //value：表单的值、item：表单的DOM对象
							if(!new RegExp("^[a-zA-Z0-9_\u4e00-\u9fa5\\s·]+$").test(value)) {
								return '用户名不能有特殊字符';
							}
							if(/(^\_)|(\__)|(\_+$)/.test(value)) {
								return '用户名首尾不能出现下划线\'_\'';
							}
							if(/^\d+\d+\d$/.test(value)) {
								return '用户名不能全为数字';
							}

							//如果不想自动弹出默认提示框，可以直接返回 true，这时你可以通过其他任意方式提示（v2.5.7 新增）
							if(value === 'name' || value === 'username' || value === 'sb') {
								return '用户名不能为敏感词';
							}
						}

						//我们既支持上述函数式的方式，也支持下述数组的形式
						//数组的两个值分别代表：[正则匹配、匹配不符时的提示文字]
						,
					pass: [
						/^[\S]{6,12}$/, '密码必须6到12位，且不能出现空格'
					]
				});
				$("#userid").val(globalData.getUid());
				//监听提交
				form.on('submit(trackstudentsBtu)', function(data) {
					$.post(globalData.server + "public/addTrack", data.field, function(data) {
						if(data.count > 0) {
							var iframeIndex = parent.layer.getFrameIndex(window.name);
							parent.layer.close(iframeIndex);
						}
					}, "json");
					return false;
				});

			});
		</script>
</body>
</html>